package com.qzsoft.zhjd.machine.modules.machinerealtime.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qzsoft.jeemis.common.utils.Result;
import com.qzsoft.zhjd.common.utils.ResultUtils;
import com.qzsoft.zhjd.machine.modules.machinerealtime.dto.MachineRealtimeDto;
import com.qzsoft.zhjd.machine.modules.machinerealtime.dto.MachineStateCountDto;
import com.qzsoft.zhjd.machine.modules.machinerealtime.service.MachineRealtimeService;

/**
 * @ClassName MachineRealtimeController
 * @Description 机械设备实时数据控制器
 * @author linhuawei
 * @since 2021-11-08
 */
@RestController
@RequestMapping("/api/machineRealtime")
public class MachineRealtimeController {

    @Autowired
    private MachineRealtimeService machineRealtimeService;

    /**
     * @Title page
     * @Description 获取实时监控分页列表
     * @param params 查询条件
     * @return 实时监控分页列表
     */
    @RequiresPermissions({"api:machinerunmanager:list"})
    @GetMapping("/page")
    public Result<IPage<MachineRealtimeDto>> page(@RequestParam Map<String, Object> params) {
        IPage<MachineRealtimeDto> page = machineRealtimeService.pageDto(params);
        return ResultUtils.ok(page);
    }

    /**
     * @Title list
     * @Description 获取实时监控信息列表
     * @param params 查询条件
     * @return 实时监控信息列表
     */
    @GetMapping("/list")
    public Result<List<MachineRealtimeDto>> list(@RequestParam Map<String, Object> params) {
        List<MachineRealtimeDto> list = machineRealtimeService.listDto(params);
        return ResultUtils.ok(list);
    }
    
    /**
     * @Title machinePage
     * @Description 获取设备分页
     * @param params 查询条件
     * @return 设备分页
     */
    @RequiresPermissions({"api:machinerealtime:list"})
    @GetMapping("/machinePage")
    public Result<IPage<MachineRealtimeDto>> machinePage(@RequestParam Map<String, Object> params){
        IPage<MachineRealtimeDto> page = machineRealtimeService.machinePage(params);
        return ResultUtils.ok(page);
    }

    /**
     * @Title count
     * @Description 获取设备统计信息
     * @param params 查询条件
     * @return 设备统计信息
     */
    @RequiresPermissions({"api:machinerealtime:list"})
    @GetMapping("/countState")
    public Result<MachineStateCountDto> countState(@RequestParam Map<String, Object> params) {
        MachineStateCountDto data = machineRealtimeService.countState(params);
        return ResultUtils.ok(data);
    }

}
